package Semantics;

public class SemanticsException {
	public static int VAR_REDEFINITION = 0;
	public static int METHOD_REDEFINITION = 1;
	public static int VAR_UNDEFINED = 2;
	public static int METHOD_UNDEFINED = 3;
	public static int CLASS_REDEFINITION = 4;
	public static int TYPE_UNDEFINED = 5;
	public static int DIFFERENT_TYPE_ASSIGN = 6;
	public static int SUPERCLASS_NOTEXISTS = 7;
	public static int RETURNTYPE_UNDEFINED = 8;
	public static int RECURSIVE_EXTENDS = 9;
	public static int PREDECL_ERROR = 10;
	public static int POSTDECL_ERROR = 11;
	public static int RETURN_TYPE_ERROR = 12;
	public static int CONDITION_ERROR = 13;
	public static int PRINT_TYPE_ERROR = 14;
	public static int INDEX_TYPE_ERROR = 15;
	public static int TYPE_MATCH_ERROR = 16;
	public static int PARAMETER_PASS_ERROR = 17;
	public static int RETURN_EARLY_ERROR = 18;
	public static int NO_RETURN_ERROR = 19;
	String[] errorImage = {
		    "VAR_REDEFINITION",
		    "METHOD_REDEFINITION",
		    "VAR_UNDEFINED",
		    "METHOD_UNDEFINED",
		    "CLASS_REDEFINITION",
		    "TYPE_UNDEFINED",
		    "DIFFERENT_TYPE_ASSIGN",
		    "SUPERCLASS_NOTEXISTS",
		    "RETURNTYPE_UNDEFINED",
		    "RECURSIVE_EXTENDS",
		    "PREDECL_ERROR",
		    "POSTDECL_ERROR",
		    "RETURN_TYPE_ERROR",
		    "CONDITION_ERROR",
		    "PRINT_TYPE_ERROR",
		    "INDEX_TYPE_ERROR",
		    "TYPE_MATCH_ERROR",
		    "PARAMETER_PASS_ERROR",
		    "RETURN_EARLY_ERROR",
		    "NO_RETURN_ERROR",
		  };
	public int etype;
	public String[] einfo;
	public int eline[];
	public SemanticsException(int type, String[] info, int[] line){
		etype = type;
		einfo = info;
		eline = line;
	}
	
	public SemanticsException(int type, String info, int line){
		etype = type;
		einfo = new String[1];
		einfo[0] = info;
		eline = new int[1];
		eline[0] = line;
	}
	public String getMessage(){
		String error_message="";
		error_message+="Semantics Error: at line "+ this.eline[0]+" "+this.errorImage[this.etype]+" "+ this.einfo[0];
		return error_message;
	}
}